﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Accounting.Library;
using Converter;
using System.Resources;
using System.Reflection;

namespace csla4Skeleton.UI.SL.DanhMuc.DM_LoaiHangHoa
{
    public partial class DM_LoaiHangHoa_ChildWindow : ChildWindow
    {
        public event EventHandler SaveClicked;
        protected DM_LoaiHangHoa_ViewModel dm_LoaiHangHoa_ViewModel;
        List<Control> controls = new List<Control>();
        public DM_LoaiHangHoa_ChildWindow()
        {
            LocalizationConverter converter = new LocalizationConverter();
            converter.LocalResourceManager = new ResourceManager("csla4Skeleton.UI.SL.DanhMuc.DM_LoaiHangHoa.Resources", Assembly.GetExecutingAssembly());
            this.Resources.Add("Localization", converter);
            InitializeComponent();
            ControlBehavior.ControlBehaviors.Navigation(this.InformationInputGrid, controls);
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                System.Windows.Data.CollectionViewSource dm_LoaiHangHoa_ViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["DM_LoaiHangHoa_ViewModelSource"];
                dm_LoaiHangHoa_ViewModel = new DM_LoaiHangHoa_ViewModel(BusinessConfiguration.Configuration.ChildWindow);
                dm_LoaiHangHoa_ViewSource.Source = new List<object> { dm_LoaiHangHoa_ViewModel };

                dm_LoaiHangHoa_ViewModel.Saved += new EventHandler(dm_LoaiHangHoa_ViewModel_Saved);
                dm_LoaiHangHoa_ViewModel.Canceled += new EventHandler(dm_LoaiHangHoa_ViewModel_Canceled);
               
                
            }
        }

        private void Control_KeyUp(object sender, KeyEventArgs e)
        {

            ControlBehavior.ControlBehaviors.Control_KeyUp(sender, e, controls);
        }
        void dm_LoaiHangHoa_ViewModel_Saved(object sender, EventArgs e)
        {
            SaveClicked(this, new EventArgs());
            this.DialogResult = true;        
        }
        void dm_LoaiHangHoa_ViewModel_Canceled(object sender, EventArgs e)
        {
            this.DialogResult = false;
        }
        
    }
}

